Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@darkwolf/validator

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@darkwolf/validator

Validator

  • 6.7.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-91.07%
Maintainers
1
Weekly downloads
 
Created
Source

Validator

Install

npm i --save @darkwolf/validator

Usage

const validator = require('@darkwolf/validator')

validator.isNumber(13) // true
validator.isString(21) // false

// Using constructor
const { Validator } = validator

new Validator(69, {throwErrors: false}).isString().isValid // false
new Validator(69).isNumber().isRange(0, 100).isValid // true
new Validator('69').isNumber() // throw error
new Validator('69', {complete: true}).isNumber().isStrictEqual(69).throw() // execute chain and throw error

Init

new Validator(value?, options[name, complete, generateMessages, throwErrors, customError])

Methods

validate(() => boolean, errorMessage || validator => errorMessage)

throw(validator => e)

isRequired()

isOptional()

is(value => !!value)

isEqual(value1?, value2)

isStrictEqual(value1?, value2)

isType(value?, type)

isClass(value?, name)

isInstance(value?, constructor)

isUndefined(value?)

isNull(value?)

isNil(value?)

isObject(value?)

isObjectLike(value?)

isPlainObject(value?)

isFunction(value?)

isAsyncFunction(value?)

isCallback(value?)

isAsyncCallback(value?)

isBoolean(value?)

isNumber(value?)

isString(value?)

isSymbol(value?)

isArray(value?)

isBuffer(value?)

isArrayBuffer(value?)

isRegExp(value?)

isSet(value?)

isMap(value?)

isPromise(value?)

isDate(value?)

isError(value?)

isTypeError(value?)

isCodeError(value?)

isValidator(value?)

isValidatorError(value?)

isValidationError(value?)

isNaN(value?)

isFinite(value?)

isInteger(value?)

isSafeInteger(value?)

isFloat(value?)

isDecimal(value?)

isInfinity(value?)

isMore(value?, number)

isLess(value?, number)

isMoreEqual(value?, number)

isLessEqual(value?, number)

isRange(value?, min, max)

isPositive(value?)

isNegative(value?)

isNonNegative(value?)

isNonPositive(value?)

isEven(value?)

isOdd(value?)

isTrue(value?)

isFalse(value?)

isRegex(value?, regex)

isExists(value?)

isLength(value?, number || ...[min, max])

isSize(value?, number || ...[min, max])

isEmpty(value?)

isHas(value?, key)

isIncludes(value1?, value2)

isIncluded(value1?, value2)

isUnique(value?)

isTimestamp(value?)

isUnixTimestamp(value?)

isUUID(value?)

isIPv4(value?)

isUrl(value?)

isEmail(value?)

isPhoneNumber(value?)

isASCII(value?)

isBase64(value?)

isBase64Url(value?)

isBase58(value?)

isJWT(value?)

Error Codes

invalid-options
invalid-name
invalid-complete
invalid-generate-messages
invalid-throw-errors
invalid-custom-error
invalid-callback
invalid-error-message

Keywords

FAQs

Package last updated on 09 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc